<?php
include_once "xAP-functions/webincludes.php";
$id=intval($_GET["id"]);

if(isset($_GET["new"])){
	if($_GET["new"]!=""){
		dbexec("insert into xAP_EventElement (EventID,Alias,Priority,Active) VALUES
		(".$id.",'".dbesc($_GET["new"])."',1,1)");
	}
}
if(isset($_GET["delete"])){
	if($_GET["delete"]!=""){
		dbexec("delete from xAP_EventElement where EventElementID=".intval($_GET["delete"])."");
	}
}



$sql="select EventElementID,Alias,Priority from xAP_EventElement where EventID=".$id." order by Priority";
$results=dbquery($sql);

echo "
<span  class='boldtext'><a href='index.php'>Events</a> / Elements</span>
<UL class='itemlist'>";
foreach($results as $row){
	echo "<LI>
	<a href='#' OnClick=\"Delete(".$row["EventElementID"].")\"><img src='/xAP-Layout/".$config["theme"]."/images/delete.gif'> </a>
	<a href='#' OnClick=\"Edit(".$row["EventElementID"].")\"><img src='/xAP-Layout/".$config["theme"]."/images/edit.gif'> ".$row["Alias"]."</a>
	
	</LI>";
}
echo "<LI><a href='#' OnClick=\"Settings(".$id.")\">Event Settings</a></LI>";
echo "</UL>";
echo "<span class='normaltext'><input id='newbox' size=20><input type='button' value='Add New' Onclick='AddNew()'></span>";
?>